<?php
/**
 * Description:
 *
 * @author      Eden
 * @datetime    2016/11/26 16:35
 * @copyright   Beijing CmsTop Technology Co.,Ltd.
 */

class Log_Login_Model extends ADM_Model
{
    /**
     * 初始化
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * 记录登录日志
     * @param $adminId
     * @param string $note
     */
    public function save($type, $note = '', $state = 1)
    {

        if (!in_array($type, array('login', 'logout'))) {
            return false;
        }

        $data = array(
            'adminId' => '',
            'type' => $type,
            'note' => $note,
            'loginIP' => remoteAddr(),
            'created' => date("Y-m-d H:i:s")
        );
        $this->db->insert('log_login', $data);
    }
}
